package com.effectiv.gooruda.rest.api.controller;

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.effectiv.gooruda.rest.api.domain.Image;
import com.effectiv.gooruda.rest.api.operation.ImageOperations;

@Slf4j
@Controller
@RequestMapping("/api/imageoperations")
public class ImageContoller implements ImageOperations{
	
	@Autowired
	private ImageOperations operations;
	
	@Override
	@RequestMapping(value="/changeformat/{name}/{format}", method=RequestMethod.POST)
	public @ResponseBody Image changeFormat(@PathVariable("name") String name,@PathVariable("newFormat") String newFormat, 
			@PathVariable("file") MultipartFile multipartFile) {
		
		operations.changeFormat(name, newFormat, multipartFile);

		
		return null;
	}

	
}
